package com.muchfish.function;

public class Lambda {


    public static void main(String[] args) {
        //2.MyInterface的实现类实例，通过匿名内部类创建
        MyInterface myInterface = new MyInterface() {
            @Override
            public int sum(int i, int j) {
                return i+j+1;
            }
        };
        //2.Lambda表达式简化函数式接口实例的创建
        //格式：(参数表) -> {方法体}
        //该格式实际为映射到函数式接口的抽象方法 sum()
        MyInterface myInterfaceLambda = (i, j) ->{
            return i+j+1;
        } ;
        System.out.println("myInterface.sum(3,4) = " + myInterface.sum(3, 4));
        System.out.println("myInterfaceLambda.sum(3,4) = " + myInterfaceLambda.sum(3, 4));
    }
}
